﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
using FazaDemo.BL.InterfaceDomain;
using FazaDemo.PL.Wpf;
using FazaDemo.QL.AbstractQueryModel;
using FazaDemo.QueryModel;
using FazaDemo.ViewModels;

namespace FazaDemo.PL.Wpf
{
    class DistrictGridFactory : DataGridFactory
    {

        private IList<DistrictViewModel> _viewModels;

        public DistrictGridFactory()
        {
            _apiClient = new WebApiClient();
        }

        public DistrictGridFactory(IDgridCustomizer customizer)
        {
            Customizer = customizer;
            _apiClient = new WebApiClient();
        }

        protected override void AddColumns()
        {
            _workDgrid.Columns.Add(new DataGridTextColumn { Header = "район" });
            _workDgrid.Columns.Add(new DataGridTextColumn { Header = "ID" });
        }

        protected override void LoadContent()
        {
            _viewModels = _apiClient.GetList<DistrictViewModel>().ToList();
            _workDgrid.ItemsSource = _viewModels;
            var nameColumn = _workDgrid.Columns[0] as DataGridTextColumn;
            nameColumn.Binding = new Binding("Name");
            var idColumn = _workDgrid.Columns[1] as DataGridTextColumn;
            idColumn.Binding = new Binding("Id");
        }

    }
}
